<%@page import="entities.Exams"%>
<%@page import="java.util.List"%>

<div class="home">
    <h2 style="text-align: left;">Exams schedule</h2>
    <div style="color:red; text-align: center"><i>${message}</i></div><br>
    <%int i = 1;
        List<Exams> exams = (List<Exams>) session.getAttribute("exams");
        if (exams != null) {
    %>
    <table class="gradesTableId" border="4">
        <tr class="gradesHeader">
            <td>
                No.
            </td>
            <td>
                Subject matter
            </td>
            <td>
                Series
            </td>
            <td>
                Class
            </td>
            <td>
                Date
            </td>
            <td>
                Hour
            </td>
            <td>
                Location
            </td>
            <td>
                Request status
            </td>
        </tr>    
        <s:iterator value="#session.exams" status="status" var="myobj">
            <s:if test="#myobj.stat==2">
                <s:set var="style" value="%{'color: white; background-color: red;'}"/>
                <s:set var="examStatus" value="%{'rejected'}"/>
            </s:if>
            <s:elseif test="#myobj.stat!=1">
                <s:set var="style" value="%{'background-color: yellow;'}"/>
                <s:set var="examStatus" value="%{'in pending'}"/>
            </s:elseif>
            <s:else>
                <s:set var="style" value="%{'background-color: white; color: black;'}"/>
                <s:set var="examStatus" value="%{'approved'}"/>
            </s:else>
            <tr style="<s:property value='style'/>">
                <td>
                    <%=i++%>
                </td>
                <td>
            <s:property value="subjectMatter.name"/>
            </td>
            <td>
            <s:property value="cls.series"/>
            </td>
            <td>
            <s:property value="cls.number"/>
            </td>
            <td>
            <s:property value="date"/>
            </td>
            <td>
            <s:property value="hour"/>
            </td>
            <td>
            <s:property value="location"/>
            </td>
            <td>
            <s:property value="examStatus"/>
            </td>
            </tr>
        </s:iterator>
    </table><%} else {%>
    <i>There are no exams scheduled!</i>
    <%}%><br>
    <s:form action="Button!scheduleExam">
        <s:submit value="Schedule exam"/>
    </s:form>
</div>

